#ifndef CONFIGFILE_H_
#define CONFIGFILE_H_

#include <string>
#include <map>

#include "File.h"

namespace Lame3d
{
	class ConfigFile
	{
		public:
			ConfigFile(const char* name);
			ConfigFile(const File &f);
			~ConfigFile();
			
			class Entry
			{
				public:
					~Entry();
					
					Entry& operator=(const std::string& s);
					Entry& operator=(int i);
					Entry& operator=(float f);
					
					const std::string& String() const;
					int Int() const;
					float Float() const;
					
					bool IsNew() const;
					
				protected:
					Entry(const std::string &v, bool iN=false);
					std::string value;
					bool isNew;
					
				friend class ConfigFile;
			};
			
			Entry& operator[](const std::string &key);
			
			Entry* Find(const std::string &key);
			
			void Save() const;
			
		protected:
			File file;
			std::map<std::string, Entry*> entries;
			
			void load(const std::string &s);
	};
}

#endif /*CONFIGFILE_H_*/
